@extends('layouts.console_header')

@section('title', '商家详情')

@section('resources')
    @parent
    <!-- css 文件 -->
    <link rel="stylesheet" href="https://cache.amap.com/lbs/static/main1119.css"/>
	<style>
		.maintenance_peo,.grade_peo{cursor: pointer;margin-left: 30px;color: #9955c6;font-style: normal}
		#maintenance{width: 400px;height: 160px;background-color: #fff;border: 1px solid #000;position: fixed;top: 250px;left: 50%;margin-left: -200px;display: none;z-index: 1001;}
		#shop_level_outer{width: 400px;height: 160px;background-color: #fff;border: 1px solid #000;position: fixed;top: 250px;left: 50%;margin-left: -200px;display: none;z-index: 1001;}
		.old_maintenance{margin: 20px auto;width: 300px;}
		.old_maintenance span{margin-left: 10px;}
		.new_maintenance{margin: 20px auto;width: 300px;}
		.new_maintenance span{margin-left: 10px;}
		#new_maintenance{border: 1px solid #000;float: left;margin-left: 10px;width: 100px;height: 25px;}
		#shop_level_select{border: 1px solid #000;float: left;margin-left: 10px;width: 100px;height: 25px;}
		.close{position: absolute;top: 10px;right: 10px;width: 20px;cursor: pointer;}
		.button{margin-top: 30px;}
		#close{width: 100px;height: 30px;background-color: #ccc;margin-left: 30px;text-align: center;line-height: 30px;}
		#systemclose{width: 100px;height: 30px;background-color: #ccc;margin-left: 30px;text-align: center;line-height: 30px;}
		#sure{width: 100px;height: 30px;background-color: #9955c6;color: #fff;margin-left: 130px;}
		#systemsure{width: 100px;height: 30px;background-color: #9955c6;color: #fff;margin-left: 130px;}
		#oldmaintainer{width: 130px;height: 20px;border: 1px solid #000;margin-left: 10px;padding: 0 5px;}
		.revise_phonenum{width: 80px;height: 20px;border: 1px solid #818181;margin-left: 30px;border-radius: 5px;text-align: center;cursor: pointer;}
        .phone_num{width: 400px;position: fixed;;top: 200px;left: 50%;margin-left: -200px;background-color: #fff;border: 1px solid #000;display: none;}
        .phone_num p{padding: 10px;}
        /*.close{width: 20px;height: 20px;}*/
        #old_phonenum,#new_phonenum{width: 150px;height: 30px;border: 1px solid #000;padding: 0 5px;}
        #phoneclose{width: 100px;height: 30px;background-color: #ccc;margin-left: 30px;text-align: center;line-height: 30px;}
        #phonesure{width: 100px;height: 30px;background-color: #9955c6;color: #fff;margin-left: 130px;}
        .big_picture{position: fixed;top: 0;left: 0;background: rgba(0,0,0,0.5);z-index: 1000;display: none;}
        .big_picture .big_pictureurl{position: absolute;top: 50%;left: 50%;}
        .big_picture .big_pictureclose{position: absolute;top: 0;right: 0;}
		#container{width: 350px;height: 200px;position: relative;border-top: 15px;margin-top: 15px;}
	</style>
@endsection

@section('content')
<!--  html内容  -->
<section class="user_list">
	<p class="big_picture">
		<img class="big_pictureclose" src="{{env('IMAGE_DOMAIN')}}images/access_delete.png" alt="">
		<img class="big_pictureurl" src="" alt="">
	</p>
	<div style="border-bottom: 2px solid #9955c6;overflow: hidden;">
		<p class="fz_14 account_title fl" style="border: none;">
		<span id="shop_detail_title" style="color: #7f7f7f;">
		    <a href="/console/index">首页></a>
		    商家版运营>
		    <a href="/console/shop/list?cityid={{$cityid}}">已上架商家列表></a>
        </span>
        <span class="co_violet">详情</span></p>
		<a onclick="history.go(-1);" href="#"><p class="fr tc back_btn">返回</p></a>
	</div>
	<div class="shop_details_outer">
		<p class="fz_16 oh" style="padding: 10px 0;">
			<span class="fl">商家级别：</span>
			<span class="fl">{{$grade}}</span>
			<i class="fl oh grade_peo">
				<img class="fl" style="width: 22px;" src="{{env('IMAGE_DOMAIN')}}images/console/amend.png" alt="">
				<span class="fl">修改</span>
			</i>
		<p class="fz_16 oh" style="padding-bottom: 10px;">
			<span class="fl">开拓人：</span>
			<span class="fl">{{$oldmaintainername}}  {{$oldmaintainermobile}}</span>
		</p>
		<p class="fz_16 oh" style="padding-bottom: 10px;">
			<span class="fl">维护人：</span>
			<span class="fl">{{$maintainername}}  {{$maintainermobile}}</span>
			<i class="oh fl maintenance_peo">
				<img class="fl" style="width: 22px;" src="{{env('IMAGE_DOMAIN')}}images/console/amend.png" alt="">
				<span class="fl">修改</span>
			</i>
		</p>
		<ul class="big_phonepicture">
			<li>
				<div class="oh shop_details_outer_title">
					<h2 class="fl">基本信息</h2>
					<a class="fr co_violet" href="/console/shop/check?shopid={{$id}}&cityid={{$cityid}}&type=basic">修改</a>
				</div>
				<div class="oh">
					<div class="fl">
						<h3>{{$name}}</h3>
						<p>
		                    <span>商家代码：</span>
		                    <span>{{$code}}</span>
		                </p>
						<p>
							<span>分类：</span>
							<span>{{$firstclassname}}-{{$secondclassname}}</span>
						</p>
						<p>
							<span>标签：</span>
							<span>{{$label}}</span>
						</p>
						<p>
							<span>前台电话：</span>
							<span>{{$contactnumber}}</span>
						</p>
						<p>
							<span>接收短信手机号码：</span>
							<span>{{$smsphone}}</span>
						</p>
						<p>
							<span>营业时间：</span>
							<span>{{$businesshours}}</span>
						</p>
						<p>
							<span>所在地：</span>
							<span>{{$provincename}}-{{$cityname}}-{{$districtname}}-{{$businessareaname}}</span>
						</p>
						<p>
							<span>地址：</span>
							<span>{{$address}}</span>
						</p>
						<p>
							<span>商家简介：</span>
							<span>{{$description}}</span>
						</p>
					</div>
					<div class="fr" id="container"></div>
				</div>

			</li>
			<li>
				<div class="oh shop_details_outer_title">
					<h2 class="fl">商家相册</h2>
					<a class="fr co_violet" href="/console/shop/check?shopid={{$id}}&cityid={{$cityid}}&type=photo">修改</a>
				</div>
				<h3>商家主图</h3>
				<div class="business_picture oh">
                    <p>
                        <img src="{{$photodomain}}{{$logo}}?x-oss-process=image/resize,m_fill,h_160,w_230/auto-orient,0" alt="">
                    </p>
                </div>
				<h3>环境图</h3>
				<div class="business_picture oh">
				@if(count($photos) >= 1)
                    @foreach($photos as $photo)
                        <p>
                            <img src="{{$photodomain}}{{$photo}}?x-oss-process=image/resize,m_fill,h_160,w_230/auto-orient,0" alt="">
                        </p>
                    @endforeach
                @endif
				</div>
				<h3>产品图</h3>
				<ol class="goods_picture">
			    @if(count($goodsphotos) >= 1)
                    @foreach($goodsphotos as $list)
                       <li class="oh">
                           <img class="fl" src="{{$photodomain}}{{$list['url']}}?x-oss-process=image/resize,m_fill,h_160,w_230/auto-orient,0" alt="">
                           <div class="fl">
                               <p>{{$list['name']}}</p>
                               <p>{{$list['description']}}</p>
                           </div>
                       </li>
                   @endforeach
                @endif
				</ol>
			</li>
			<li>
				<div class="oh shop_details_outer_title">
					<h2 class="fl">翻倍日</h2>
					<a class="fr co_violet" href="/console/shop/check?shopid={{$id}}&cityid={{$cityid}}&type=doublecalendar">修改</a>
				</div>
				<p>每周最多{{$weekdoubleday}}个翻倍日</p>
				<p style="width: 1150px;">{{$shopevent}}</p>
				{{--<p style="margin-top:20px;">翻倍日备注:&nbsp;&nbsp;&nbsp;&nbsp;{{$eventremark}}</p>--}}
			</li>
			<li>
				<div class="oh shop_details_outer_title">
					<h2 class="fl">代付规则</h2>
					<a class="fr co_violet" href="/console/shop/check?shopid={{$id}}&cityid={{$cityid}}&type=payrules">修改</a>
				</div>
				<h3>代付范围</h3>
				@if(($notpartakegoods == '') ||($notpartakegoods == '无'))
                   <p> 全场参与，
				@else
                    <p>全场参与，除{{$notpartakegoods}}外，
				@endif
				@if($maxsales == 0)
				
				@else
				    {{$maxsales}}元封顶，
				@endif
				@if($buynumber == 0)
					当天每个用户不限买单次数</p>
				@else
					当天一个用户仅限{{$buynumber}}单</p>
				@endif

				<h3>发票</h3>
				<p>{{$invoice}}</p>
				<h3>其他</h3>
				<p>{{$content}}</p>
				<h3>温馨提示</h3>
				<p>为避免商品价格不实，翻贝网平台不显示商家价格，以用户和实体店最终议价为准，最后通过翻贝网代付。翻贝网热线：400-6989-820</p>
			</li>
			<li>
				<div class="oh shop_details_outer_title">
					<h2 class="fl">收款账号</h2>
					{{--<a class="fr co_violet" href="/console/shop/check?shopid={{$id}}&cityid={{$cityid}}&type=payaccount">修改</a>--}}
				</div>
				<p>持卡人：{{$cardholder}} </p>
				<p>身份证号：{{$idcard}}</p>
				<p>银行卡号：{{$bankcard}}</p>
				<p>银行：{{$bankname}}</p>
				<p>开户行：{{$bankprovince.$bankcity.$opencardbank}}</p>
			</li>
			<li>
				<div class="oh shop_details_outer_title">
					<h2 class="fl">法人/门店负责人信息</h2>
					<a class="fr co_violet" href="/console/shop/check?shopid={{$id}}&cityid={{$cityid}}&type=legalperson">修改</a>
				</div>
				<p>负责人姓名：{{$parentname}} </p>
				<p style="overflow: hidden;">
				    <span class="fl">商家登录帐号：{{$parentmobile}}</span>
				    <span class="revise_phonenum fl">修改手机号</span>
                </p>
				<p>合约开始时间：{{$contractstarttime}}</p>
				<p>合约截止时间：{{$contractendtime}}</p>
			</li>
			<li>
				<div class="oh shop_details_outer_title">
					<h2 class="fl">经营资质</h2>
					<a class="fr co_violet" href="/console/shop/check?shopid={{$id}}&cityid={{$cityid}}&type=qualification">修改</a>
				</div>
				<ol class="shop_picture oh">
					<li class="fl">
						<p>银行卡正面照</p>
						<img src="{{$photodomain}}{{$bankcardphoto}}?x-oss-process=image/resize,m_fill,h_160,w_230/auto-orient,0" alt="">
					</li>
					<li class="fl">
						<p>营业执照</p>
						<img src="{{$photodomain}}{{$licensephoto}}?x-oss-process=image/resize,m_fill,h_160,w_230/auto-orient,0" alt="">
					</li>
					<li class="fl">
						<p>身份证正面照</p>
						<img src="{{$photodomain}}{{$idcardfrontphoto}}?x-oss-process=image/resize,m_fill,h_160,w_230/auto-orient,0" alt="">
					</li>
					<li class="fl">
						<p>身份证反面照</p>
						<img src="{{$photodomain}}{{$idcardbackphoto}}?x-oss-process=image/resize,m_fill,h_160,w_230/auto-orient,0" alt="">
					</li>
				</ol>
			</li>
			{{--<li>
				<div class="oh shop_details_outer_title">
					<h2>商家状态记录</h2>
				</div>
				<ol class="business_record">
					<li>
						<p>审核人：{{$firstverifyname}} {{$firstverifymobile}}</p>
						<p>审核时间：{{date('Y-m-d H:i:s', strtotime($firstverifytime))}}</p>
						<!--<p>状态：</p>-->
						<p>审核备注：{{$firstverifynote}}</p>
					</li>
					<li>
						<p>审核人：{{$lastverifyname}} {{$lastverifymobile}}</p>
						<p>审核时间：{{date('Y-m-d H:i:s', strtotime($lastverifytime))}}</p>
						<!--<p>状态：下架</p>-->
						<p>审核备注：{{$lastverifynote}}</p>
					</li>
				</ol>
			</li>--}}
		</ul>
		<form action="" method="" id="maintenance" target="nm_iframe">
			<p><img class="fr close" src="{{env('IMAGE_DOMAIN')}}images/close_p.png" alt=""></p>
			<input type="hidden" name="shopid" value="{{$id}}" />
			<input type="hidden" name="cityid" value="{{$cityid}}" />
			<input type="hidden" name="updaterole" value="new" />
			<p class="oh old_maintenance">
				<span class="fl">原维护人：</span>
				<span class="fl">{{$maintainername}}</span>
				<span class="fl">{{$maintainermobile}}</span>
			</p>
			<p class="oh new_maintenance">
				<span class="fl">新维护人：</span>
				<select name="maintainerid" id="new_maintenance">

				</select>
			</p>
			<p class="button oh">
				<span id="close" class="fl">取消</span>
				<input class="fl" type="button" id="sure" name="" value="确定">
			</p>
		</form>
		<form action="" method="" id="shop_level_outer" target="nm_iframe">
			<p><img class="fr close" src="{{env('IMAGE_DOMAIN')}}images/close_p.png" alt=""></p>
			<input type="hidden" name="shopid" value="{{$id}}" />
			<input type="hidden" name="cityid" value="{{$cityid}}" />
			<p class="oh old_maintenance">
				<span class="fl">当前商家级别：</span>
				<span class="fl">{{$grade}}</span>
			</p>
			<p class="oh new_maintenance">
				<span class="fl">商家级别：</span>
				<select name="shopgrade" id="shop_level_select">
					<option value="0">请选择</option>
					<option value="A级">A级</option>
					<option value="B级">B级</option>
					<option value="C级">C级</option>
					<option value="D级">D级</option>
				</select>
			</p>
			<p class="button oh">
				<input type="hidden" name="grade" value="">
				<span id="systemclose" class="fl">取消</span>
				<input class="fl" type="button" id="systemsure" name="" value="确定">
			</p>
		</form>
		<form action="" method="" class="phone_num" target="nm_iframe">
	        <p class="oh phone_num_title">
	            <span class="fl">修改法人手机号</span>
	            <img class="fr close" src="{{env('IMAGE_DOMAIN')}}images/close_p.png" alt="">
	        </p>
	        <p class="oh ">
	            <span class="fl">原法人手机号：</span>
	            <input type="text" name="oldparentmobile" id="old_phonenum" value="" maxlength="11" onkeyup="value=value.replace(/[^\d]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
	            <span class="phone_num_oldparentmobile" style="font-size: 14px;color: red;margin: 0;display: none;">请输入11位数字</span>
	        </p>
	        <p class="oh ">
	            <span class="fl">新法人手机号：</span>
	            <input type="text" name="newparentmobile" value="" id="new_phonenum" maxlength="11" onkeyup="value=value.replace(/[^\d]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
	            <span class="phone_num_newparentmobile" style="font-size: 14px;color: red;margin: 0;display: none;">请输入11位数字</span>
	        </p>
	        <p id="phone_message"></p>
	        <p class="button oh">
	            <input class="fl" type="button" id="phonesure" name="" value="确定">
	            <span id="phoneclose" class="fl">取消</span>
	        </p>
	    </form>
		<iframe id="id_iframe" name="nm_iframe" style="display:none;"></iframe>
	</div>
	<!--
	<div style="margin: 10px;">
		<button style="background-color: #9955c6;">提交审核</button>
		<button>取消</button>
	</div>
	-->
</section>
@endsection

@section('scriptResources')
    @parent
    <!-- js 文件-->
    <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.3&key=a9fe1b184bacd00ecd70365903024419&plugin=AMap.Autocomplete"></script>
    <script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script>
<script>
    var cityid='{{$cityid}}';
    var shopid='{{$id}}';
    var mylongitude='{{$longitude}}';
    var mylatitude='{{$latitude}}';
    var lasturl = document.referrer;
    if(lasturl.indexOf('/console/shop/status/list')>=0){
        $("#shop_detail_title").html('<a href="/console/index">首页></a>商家版运营> <a href="/console/shop/status/list?cityid={{$cityid}}">商家状态列表></a>');
	}else if(lasturl.indexOf('/console/shop/downshelf/list')>=0){
        $("#shop_detail_title").html('<a href="/console/index">首页></a>商家版运营> <a href="/console/shop/downshelf/list?cityid={{$cityid}}">已下架商家列表></a>');
	}else if(lasturl.indexOf('/console/shop/lastevent/list')>=0){
        $("#shop_detail_title").html('<a href="/console/index">首页></a>商家版运营> <a href="/console/shop/lastevent/list?cityid={{$cityid}}">商家续签管理列表></a>');
	}else if(lasturl.indexOf('/console/shop/list')>=0){
        $("#shop_detail_title").html('<a href="/console/index">首页></a>商家版运营> <a href="/console/shop/list?cityid={{$cityid}}">已上架商家列表></a>');
	}
    //地图
    var marker,map = new AMap.Map("container", {
        resizeEnable: true,
        center: [mylongitude, mylatitude],
        zoom: 13
    });
  	function addMarker() {
	    marker = new AMap.Marker({
	        icon: "http://webapi.amap.com/theme/v1.3/markers/n/mark_b.png",
	        position: [mylongitude, mylatitude]
	    });
	    marker.setMap(map);
	}
	addMarker()
	function revise(id){
		$("#oldmaintainer").val($(id).val())
	}
	$(function(){
		var bodytop;
		var wh = $(window).height();
		var dh = $(document).height();
		$(".big_picture").width($(window).width());
		$(".big_phonepicture img").on("click",function(){       //大图模式
			bodytop = $("body").scrollTop();
			$(".big_picture").show();
			$(".big_picture").height($(window).height());
			console.log($(window).height())
			console.log($(document).height())
			var currenturl = $(this).attr("src");
			var currenturlarr = currenturl.split('?')
			$(".big_pictureurl").attr("src",currenturlarr[0]);
			setTimeout(function(){
				if($(".big_pictureurl").height() < $(".big_pictureurl").width()){
					$(".big_pictureurl").css({"height":"auto","width":"90%"});
					var pich = $(".big_pictureurl").height();
					var picw = $(".big_pictureurl").width();
					$(".big_pictureurl").css({"margin-top": -pich/2,"margin-left": -picw/2});
				}else{
					$(".big_pictureurl").css({"height":"90%","width":"auto"});
					var pich = $(".big_pictureurl").height();
					var picw = $(".big_pictureurl").width();
					$(".big_pictureurl").css({"margin-top": -pich/2,"margin-left": -picw/2});
				}
			},200)
			// $(document.body).css({"overflow":"hidden","height":wh});
	  //   	$("html").css({"overflow":"hidden","height":wh});
			$(".big_pictureclose").click(function(){
				// $("body").scrollTop(bodytop);
				// $(document.body).css({"overflow":"visible","height":dh});
	    		// $("html").css({"overflow":"visible","height":dh});
				$(".big_picture").hide();
			})
		})
		$(".revise_phonenum").click(function(){  //修改法人手机号
            $(".phone_num").show();
        })
        $(".close").on("click",function(){      //修改法人手机号
            $(".phone_num").hide();
        })
        $("#phoneclose").on("click",function(){    //修改法人手机号
            $(".phone_num").hide();
        })
        $("#phonesure").on("click",function(){  //修改法人手机号
            $("#phonesure").attr({"disabled":"disabled"});
            var oldparentmobile = $(".phone_num input[name='oldparentmobile']").val();
            var newparentmobile = $(".phone_num input[name='newparentmobile']").val();
            $(".phone_num_oldparentmobile").hide();
            $(".phone_num_newparentmobile").hide();
            if(oldparentmobile.length!=11||isNaN(oldparentmobile)){
            	$(".phone_num_oldparentmobile").show();
                $("#phonesure").removeAttr("disabled");
            }else if(newparentmobile.length!=11||isNaN(newparentmobile)){
            	$(".phone_num_newparentmobile").show();
                $("#phonesure").removeAttr("disabled");
            }else{
            	$.ajax({
	                url : '/console/shop/parentmobile/update',
	                data:{
	                    cityid:cityid,
	                    shopid:shopid,
	                    oldparentmobile:oldparentmobile,
	                    newparentmobile:newparentmobile,
	                    type:'shop'
	                    },
	                dataType:'json',
	                type:'post',
	                success:function(data){
	                    if(data.status == 'success') {
	                        alert(data.message);
	                        //$(".phone_num").hide();
	                        window.location.href="/console/shop/get?cityid="+cityid+"&shopid="+shopid+"&now="+Date.parse(new Date());
	                    } else {
	                        alert(data.message);
                            $("#phonesure").removeAttr("disabled");
	                    }
	                },
	                error: function(XMLHttpRequest, textStatus, errorThrown) {
	                    alert(XMLHttpRequest.status);
                        $("#phonesure").removeAttr("disabled");
	                }
	            });
            }  
        })
		$(".grade_peo").on("click",function(){//修改商家级别
            $("#shop_level_outer").show();
            $('.public_prompt_mark').show();
            $('.public_prompt_mark').height($(window).height());
		})
        $(".close").on("click",function(){
            $("#shop_level_outer").hide();
            $('.public_prompt_mark').hide();

        })
        $("#systemclose").on("click",function(){
            $("#shop_level_outer").hide();
            $('.public_prompt_mark').hide();
        })
		//通过绑定change事件，当下拉框内容发生变化时事件被启动grade
		$("#shop_level_select").bind("change",function(){
			//获取自定义属性的值
			var grade = $(this).find("option:selected").attr("value");
			$("input[name='grade']").val(grade);
		});
        $("#systemsure").on("click",function(){
            if ($("#shop_level_select").val() == 0){
                alert("请选择商家级别")
			}else {
                $.ajax({
                    url : '/console/shop/grade/update',
                    data:$("#shop_level_outer").serialize(),
                    dataType:'json',
                    type:'post',
                    success:function(data){
                        console.log(data);
                        if(data.status == 'success') {
                            alert(data.message);
                            window.location.reload();
                        } else {
                            alert(data.message);
                        }
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {

                    }
                });
                $("#shop_level_outer").hide();
                $('.public_prompt_mark').hide();
			}

        })
		$(".maintenance_peo").on("click",function(){//维护人修改
			var cityid = '{{$cityid}}';
			$.ajax({
                url : '/console/admin/account/getbyrole',
                data:{'cityid':cityid},
                dataType:'json',
                type:'get',
                success:function(data){
                    if(data.status == 'success') {
                        var data=data.data;
                        var str = '';
                        for(var i=0; i<data.length;i++) {
                            var list = data[i];
                            str += '<option value="'+ list.id +'">' + list.realname + '</option>';
                        }
                    } else {
                        var str = '';
                    }
                    console.log(str)
                    $("#new_maintenance").html(str);
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
            $("#maintenance").show();
            $('.public_prompt_mark').show();
            $('.public_prompt_mark').height($(window).height());
		})
        $(".close").on("click",function(){
            $("#maintenance").hide();
            $('.public_prompt_mark').hide();

        })
        $("#close").on("click",function(){
            $("#maintenance").hide();
            $('.public_prompt_mark').hide();
        })
        $("#sure").on("click",function(){
            $.ajax({
                url : '/console/shop/maintainer/update',
                data:$("#maintenance").serialize(),
                dataType:'json',
                type:'post',
                success:function(data){
                    if(data.status == 'success') {
                        alert(data.message);
                        window.location.reload();
                    } else {
                        alert(data.message);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {

                }
            });
            $("#maintenance").hide()
            $('.public_prompt_mark').hide();
        })
	})
</script>
@endsection